home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / text / hints / volume_01 / issue_10 < prev    next >
Text File  |  1995-02-16  |  15KB  |  424 lines

  1. •   BASIC Editor. If you type “EDIT.” instead of just “EDIT”, it gets
  2. you back into the editor at the same place you left it. This can be very
  3. useful when editing long programs. It even seems to work if you load and
  4. save other programs in the interim as long as you get the original
  5. program back into memory. Also, you can say EDIT Fred and it will take
  6. you to the first occurrence of the word “Fred” in the file. So, with
  7. judicious use of REM statements, you can jump into the program at just
  8. the right place every time. If you want to find DEFPROCfred, EDIT fred
  9. will probably bring you to PROCfred rather than the definition itself,
  10. but REM !FRED above the top of the procedure would allow you to type
  11. EDIT !FRED (note, all uppercase, which is easier to type) to drop you
  12. straight to the desired place in the program.
  13. 1.10
  14. •   Artisan — fast load and save. If you have typed in the Fastload/Save
  15. module from the March issue of Archive, *COPY FastRm onto the Artisan
  16. disk and then LOAD “ART3”, list line 270 and add *RMLOAD FastRm|M and
  17. then re-save it. Now LOAD “ART5” change line 2540 to OSCLI“FastLoad ”+f$
  18. and line 2620 to OSCLI”FastSave “+f$. Then re-save it. You now have a
  19. new and improved disc facility for Artisan.
  20. 1.10
  21. •   305, 310, 410 or 440? Following on from the hint in the May issue
  22. (page 7) itÕs all very well to know what the page size is, 8k or 32k,
  23. but to differentiate between a 305 and a 310 or between a 410 and a 440,
  24. you need to know how much memory is available. One way of doing this is
  25. to set up a local error trap and do a *Configure Spritesize 128. If the
  26. machine has 1 Mbyte or less it will generate a “Configure parameter too
  27. big” error. If it still generates an error when you use *Configure
  28. Spritesize 64 then the software knows it is running in a 305. We have
  29. not had chance to check this on a 305 or a 410, so please will someone
  30. let us know if it does not work.
  31. 1.10
  32. •   System DeltaPlus. If you want to use two drives, issue the following
  33. two commands from the card index:
  34. 1.10
  35. *dir :1
  36. 1.10
  37. *set Delta$WPPrefix :0.$
  38. 1.10
  39. Then donÕt specify the drive number in the data file name.
  40. 1.10
  41. •   View 3 & Viewstore 1.1. Various folk are still having problems with
  42. these. If so, try the following as suggested by Sean Kelly — thanks.
  43. 1.10
  44. Viewstore 1.1. Locations &ABE2, &ABE3 and &ABE4 should all be set to the
  45. value &EA.
  46. 1.10
  47. View 3. Set locations &A8D6, &A8D7 and &A8D8 to the value &EA. Also,
  48. there are four places where you get LDA#&82, JSR Osbyte (i.e. &A9, &82,
  49. &20, &F4, &FF). This is used to check for the second processor on the
  50. BBC. So to fool it, you have to change each of these to: LDX#&FF,
  51. LDY#&FF, NOP. You can either do this by poking &A2, &FF, &A0, &FF, &EA
  52. into each of the sets of locations: &8834 to &8838, &88D8 to &88DC,
  53. &895C to &8960 and &AF8D to &AF91. (I checked these locations against
  54. the B3.0 version in the Master 128Õs and it bore no resemblance to it.
  55. Apparently it refers to the A3.0 version. Ed.)
  56. 1.10
  57. •   Improved sound. If you have the colour monitor that comes with the
  58. Archimedes, you can use the Audio Input at the back of the monitor (a
  59. phono socket) to take a signal from the Headphones output (3.5 mm stereo
  60. jack) from the Archimedes. Just use one of the channels or combine them
  61. with 100R resistors. (If youÕre not quite sure how to do this, weÕll try
  62. to give more details next month.) This give a much better sound and
  63. provides you with a volume control.
  64. 1.10
  65. Next two hints are from Peter KigginsÉ
  66. 1.10
  67. •   When using a SWI from BASIC which either takes or returns a string,
  68. it is not necessary to use pointers to strings.  The SYS command knows
  69. that a pointer has been returned by the SWI and copies the relevant text
  70. into the string.  For example, instead of
  71. 1.10
  72. $TxtPtr%=Number$
  73. 1.10
  74. SYS“OS_ReadUnsigned”,FromBase%,TextPtr% TO ,,Decimal%
  75. 1.10
  76. you can use the more readable and easier
  77. 1.10
  78. SYS“OS_ReadUnsigned”,FromBase%,Number$ TO ,,Decimal%
  79. 1.10
  80. And to read the command line which started the program, all that’s
  81. required is
  82. 1.10
  83. SYS “OS_GetEnv” TO Command_line$
  84. 1.10
  85. •   BASIC commands TWIN and TWINO can be used without Acorn’s (editor)
  86. TWIN.  How?  When TWIN is executed, BASIC first converts the current
  87. program from internal tokenised format to plain text format; then it
  88. calls TWIN with the location of the text as a command line string.  So
  89. all that is required is a program called TWIN which reads the command
  90. line and saves the relevant chunk of memory:-
  91. 1.10
  92.  10 REM >twin
  93. 1.10
  94.  20 REM*** fails with very short pieces of text ***
  95. 1.10
  96.  30 SYS “OS_GetEnv” TO command_line$
  97. 1.10
  98.  40 posat%=INSTR(command_line$,“@”)
  99. 1.10
  100.  50 poscomma%=INSTR(command_line$,“,”,posat%)
  101. 1.10
  102.  60 possemic%=INSTR(command_line$,“;”,poscomma%)
  103. 1.10
  104.  70 start$=“&”+MID$(command_line$,posat%+1,poscomma%-(posat%+1))
  105. 1.10
  106.  80 finish$=“&”+MID$(command_line$,poscomma%+1,possemic%-(poscomma%+1))
  107. 1.10
  108.  90 INPUT“Enter file name: ” file$
  109. 1.10
  110. 100 OSCLI(“save ”+file$+“ ”+start$+“ ”+finish$)
  111. 1.10
  112. 110 OSCLI(“settype ”+file$+“ &FFF”)
  113. 1.10
  114. The point of all this is that the BASIC Editor can now be used to
  115. produce text files — for wordprocessing, compiling, etc.
  116. 1.10
  117. •   Auto-Booting — some of the commercial auto-boot programs don’t take
  118. into account the filing system! This can be very annoying if you have a
  119. ROM podule and your system is set to start up in the RFS. The answer is
  120. (i) the software developers should produce proper auto-boot programs; or
  121. (ii) if you already have bought a program — put *CON.FILE.ADFS in auto-
  122. boot program!
  123. 1.10
  124. Hard Disc Auto-Booting — some readers are lucky enough to have hard
  125. discs. However, life with a hard disc is not all a bed of roses! Having
  126. copied your application programs to the hard disc, you run into problems
  127. with the auto-booting routines. Here is a one of many possible solu
  128. tions. Indeed this program could be used for those of us with floppies,
  129. who have more than one application on a disc.
  130. 1.10
  131.  10 REM >$.!BOOT
  132. 1.10
  133.  20 REM **************************
  134. 1.10
  135.  30 REM * Multiple  Auto-Booting *
  136. 1.10
  137.  40 REM * written by Adrian Look *
  138. 1.10
  139.  50 REM *     22nd June 1988     *
  140. 1.10
  141.  60 REM **************************
  142. 1.10
  143.  70
  144. 1.10
  145.  80 SYS “OS_Byte”,161,16 TO ,,misc_flags
  146. 1.10
  147.  90 auto_boot=(misc_flags AND %10000)
  148. 1.10
  149. 100 file$=“boot”
  150. 1.10
  151. 110 file=OPENIN(file$):CLOSE #file
  152. 1.10
  153. 120 IF file=0 THEN PROCmenu
  154. 1.10
  155. 130 file=OPENIN(file$)
  156. 1.10
  157. 140 INPUT #file,boot$
  158. 1.10
  159. 150 CLOSE #file
  160. 1.10
  161. 160 IF auto_boot THEN OSCLI(“REMOVE ”+file$)
  162. 1.10
  163. 170 OSCLI(“RUN ”+file$)
  164. 1.10
  165. 180 END
  166. 1.10
  167. 190
  168. 1.10
  169. 200 DEFPROCmenu
  170. 1.10
  171. 210 REM **** your own code ****
  172. 1.10
  173. 220 REM
  174. 1.10
  175. 230 REM should exit with file$
  176. 1.10
  177. 240 REM containing the filename
  178. 1.10
  179. 250 REM of the program to be run.
  180. 1.10
  181. 260 REM
  182. 1.10
  183. 270 REM e.g. PRINT #file,filename$
  184. 1.10
  185. 280 ENDPROC
  186. 1.10
  187. The program checks whether a file (file$) is on the disk. If it is, then
  188. the program reads the filename contained in file$ and runs it! Other
  189. wise, the program should create file$ — as indicated.
  190. 1.10
  191. This method also allows you to write library programs which will: create
  192. file$ and then run the boot program. Thus by running these library files
  193. you can also initiate your application programs — without the need for a
  194. menu!
  195. 1.10
  196. •   Quazer Fix. If you are using Quasar 1.40, here is a cheat, (for
  197. those who like such things!) which allows you to keep going a bit
  198. longer. Firstly, *LOAD QuazCode 9000 and then rename Quazcode as, say,
  199. OldCode. Now if you want to set the number of lives, you need to change
  200. location &3D058. It should currently contain 2, so to change the number
  201. of lives to, say 10, put ?&3D058=10. Now if you want to avoid being
  202. killed when you collide, change the contents of location &3D90B from &E2
  203. to &F2 by puting ?&3D90B=&F2. Finally, *SAVE QuazCode 9000 +36520.
  204. 1.10
  205. •Passwords if you want them. Quazer Passwords: 2 Lizards, 3 Spiders, 4
  206. Pedantic, 5 Analysis, 6 Larkin, 7 Company, 8 Manual,9 Trading
  207. 1.10
  208. Hoverbod passwords: 2 Minervas, 3 SirBarry, 4 ZotyBlob, 5 Flumpies, 6
  209. Squidgee, 7 Wobblies, 8 Posskett
  210. 1.10
  211.  
  212. 1.10
  213. The following Hints & Tips were sent in by Mike Harrison (of Watford
  214. Digitiser fame). HeÕs also sent us various other bits of information
  215. which appear elsewhere in this issue and the next issue. Many thanks
  216. Mike.
  217. 1.10
  218. Writing modules
  219. 1.10
  220. (Ref. issue 5, page 45) SWIs in modules must always use the ‘X’ version
  221. of the SWI and, where appropriate, check for an error and exit,
  222. preserving the value of r0 returned by the SWI (i.e. don’t restore the
  223. old value of R0 if it had been saved). e.g.
  224. 1.10
  225. .a_module_routine
  226. 1.10
  227. STMFD R13!,{r0-2 ,14} \or however many registers you need to save
  228. 1.10
  229. SWI “XOS_SomethingOrOther”
  230. 1.10
  231. STRVS R0,[R13] \overwrite old r0 with error pointer
  232. 1.10
  233. LDMVSFD R13!,{r0-2 ,PC}
  234. 1.10
  235. \ the last 2 statements could alternatively have been :
  236. 1.10
  237. \
  238. 1.10
  239. \ ADDVS R13,R13,#4 : LDMVSFD R13!,{r1-2 ,PC}
  240. 1.10
  241. For short routines, or where several SWIs are used, the following is
  242. neater..
  243. 1.10
  244. .a_short_routine
  245. 1.10
  246. STMFD R13!,{r0-5 ,14}
  247. 1.10
  248. SWI “XOS_SomeSwi”
  249. 1.10
  250. SWIVC “XOS_SomethingElse”
  251. 1.10
  252. SWIVC “XOS_YetAnotherSwi”
  253. 1.10
  254. STRVS R0,[R13]
  255. 1.10
  256. LDMFD R13!,{r0-5 ,PC}
  257. 1.10
  258. In this example, all code after first SWI should be conditional on V
  259. clear, so if any SWI gives an error, the code will ‘drop through’ to the
  260. end.
  261. 1.10
  262. Remember that some SWIs may return errors you don’t expect — e.g.
  263. OS_WriteC could return an error when output is *Spooled, setting the
  264. screen mode could give ‘Bad Mode’ etc. — some thought is required to
  265. ensure that module code will be reliable in all environments.
  266. 1.10
  267. When setting up offsets in headers and command tables, it is much easier
  268. to specify them when using offset assembly (OPT 4/6/7) — set O% to the
  269. code buffer, and P% to 0. Offsets can then be included directly with
  270. EQUD (e.g. EQUD moduletitle). Warning — if you are still using Basic
  271. 1.00, there is a bug in ALIGN when using offset assembly. Version 1.02
  272. is OK.
  273. 1.10
  274. The following assembler macro is useful when building keyword tables in
  275. modules (it assumes the use of offset assembly, as described above):
  276. 1.10
  277. DEF FNcommand(I%,A$)
  278. 1.10
  279. [ OPTpass : EQUS A$ : EQUB0 :
  280. 1.10
  281. ALIGN
  282. 1.10
  283. EQUD EVAL(A$)
  284. 1.10
  285. EQUD I%
  286. 1.10
  287. EQUD EVAL(A$+“syntax”)
  288. 1.10
  289. EQUD EVAL(A$+“help”)
  290. 1.10
  291. ]:=pass
  292. 1.10
  293. OPT FNcommand(“NewCmd”,N) will create a table entry, using the labels
  294. .NewCmd .NewCmdhelp and .NewCmdsyntax (N is the information word).
  295. 1.10
  296. Note that ‘pass’ is the name of the pass variable — change this if you
  297. use a different name.
  298. 1.10
  299. Podule manager/Clock slowdown
  300. 1.10
  301. (Ref. issue 7, page 44) The problem here is that SWIs are passed to
  302. modules with interrupts disabled, so if the SWI takes a significant
  303. amount of time to complete, the clock will slow down (the mouse pointer
  304. will also become sluggish). I can’t see why the podule manager should
  305. need interrupts off, so it’s probably an unintended ‘feature’ — SWI code
  306. which takes time to execute SHOULD enable interrupts, unless they have
  307. to be off. (The digitiser module only runs with interrupts off when
  308. absolutely necessary!) When interrupts have been disabled for signifi
  309. cant amounts of time, the seconds count of the real-time clock gets out
  310. of step with the minutes, which then don’t roll over at 59 secs — this
  311. looks weird if you don’t know about it!
  312. 1.10
  313. System Devices
  314. 1.10
  315. (Ref. issue 6, page 41) There is a very interesting feature, which I
  316. haven’t seen documented, concerning device oriented filing systems. When
  317. you set the printer type using *FX5,n where n is greater than 2, the OS
  318. looks for a system variable called printertype$n — n being the value
  319. used for FX5. This variable holds the name of the output file or device
  320. to which printer output should be sent. The Econet module, NetPrint,
  321. uses this to set printer type 4 to “netprint:”. What happens is that
  322. when you do <ctrl-B>, a file is opened, with the name given in this
  323. system variable, and <ctrl-C> closes the file. While this would normally
  324. send output to a hardware device, it can also use the name of a normal
  325. file; e.g.
  326. 1.10
  327. *set printertype$5 outfile
  328. 1.10
  329. *fx5 5
  330. 1.10
  331. Will cause subsequent printer output to be written to the file “outfile”
  332. — handy for debugging, and for saving data to print on other machines.
  333. Note that this will only work if a program does VDU2, sends ALL its
  334. output, then does VDU3. If it keeps turning the printer on and off all
  335. the time with VDU2/3, only the last part of the output will be in the
  336. file, as VDU2 re-opens the file, discarding its previous contents.
  337. (Econet users know only too well the problems caused by software not
  338. handling the printer correctly!)
  339. 1.10
  340. Just for fun, try :
  341. 1.10
  342. *set printertype$5 vdu:
  343. 1.10
  344. *fx5 5
  345. 1.10
  346. <Ctrl-B>
  347. 1.10
  348. All vdu output will appear ttwwiiccee!! — once via the normal route, and
  349. again via the printer stream.
  350. 1.10
  351. Use of SYS
  352. 1.10
  353. (Ref. issue 9, page 47) The following is a bomb-proof version of OSCLI
  354. in BASIC, which will report errors without entering BASICs error handler
  355. (it can also be used for other SWIs — e.g. OS_File to trap filing errors
  356. neatly)
  357. 1.10
  358. DEFPROCoscli(OS$)
  359. 1.10
  360. LOCAL flag%,error%
  361. 1.10
  362. SYS“XOS_CLI”,OS$ TO error% ; flag%
  363. 1.10
  364. IF flag% AND 1 THEN P.“Error : ”;:SYS“OS_Write0”,error%+4
  365. 1.10
  366. REM the error number can be read using !error%
  367. 1.10
  368. ENDPROC
  369. 1.10
  370. It works by reading back the V flag and error pointer returned by the X
  371. version of the SWI
  372. 1.10
  373. TWIN
  374. 1.10
  375. (Ref. issue 7, page 7) You can warm start Twin using *Twin -warm, using
  376. the same version of Twin, of course — *GO may cause problems if the code
  377. has been corrupted, (or you’ve forgotten the address!). There is a bug
  378. in all the versions of Twin I’ve seen (I’m not sure what version has
  379. been released), which means that when exiting from TWIN to BASIC, the
  380. event vector is messed up, so if you overwrite the address where Twin
  381. was run, and enable events, the machine crashes. This can be avoided by
  382. doing QUIT, *BASIC, and OLD.
  383. 1.10
  384. In one issue, there was a tip for entering ARMBE automatically at the
  385. line in error — here’s a similar routine if you prefer using TWIN to
  386. edit BASIC programs — It uses the TWINO8 option to strip line numbers
  387. (which you don’t need to use, DO YOU!!). If the error wasn’t Escape,
  388. pressing <Y> will enter TWIN at the line where the error occurred. Note
  389. that it assumes lines are numbered in 10s — this will be the case if the
  390. program has been edited in TWIN without line numbers, but not if lines
  391. have been inserted/deleted from the BASIC prompt — in this case, enter
  392. TWIN, and exit again, or do RENUMBER.
  393. 1.10
  394. ON ERROR PROCERR
  395. 1.10
  396. ...
  397. 1.10
  398. ...
  399. 1.10
  400. DEFPROCERR
  401. 1.10
  402. REPORT:PRINT“ at line ”ERL
  403. 1.10
  404. IF ERR=17 END
  405. 1.10
  406. PRINT“EDIT ?”:IF GET$=“Y” ELSE END
  407. 1.10
  408. *FX138 0 129
  409. 1.10
  410. *FX138 0 128
  411. 1.10
  412. FORA%=1 TO LEN(STR$(ERL DIV10))
  413. 1.10
  414. SYS 6,138,,ASC(MID$(STR$(ERL DIV10),A%,1))
  415. 1.10
  416. NEXT:*FX138 0 13
  417. 1.10
  418. END
  419. 1.10
  420. Hidden software
  421. 1.10
  422. (Ref. issue 9, page 4)  Take a close look at the digitiser module!
  423. 1.10
  424.